﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;

namespace Teigha.Core
{
	public class OdGsMaterialNode : OdGsNode
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdGsMaterialNode(IntPtr cPtr, bool cMemoryOwn) : base(GlobalsPINVOKE.OdGsMaterialNode_SWIGUpcast(cPtr), cMemoryOwn)
		{
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdGsMaterialNode obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdGsMaterialNode()
		{
			this.Dispose();
		}

		public override void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							GlobalsPINVOKE.delete_OdGsMaterialNode(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
			base.Dispose();
		}

		public new static OdGsMaterialNode cast(OdRxObject pObj)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGsMaterialNode_cast(OdRxObject.getCPtr(pObj));
			OdGsMaterialNode result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGsMaterialNode)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGsMaterialNode)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGsMaterialNode)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdRxClass desc()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGsMaterialNode_desc(), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxClass isA()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGsMaterialNode_isA(this.swigCPtr), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxObject queryX(OdRxClass protocolClass)
		{
			OdRxObject result = Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGsMaterialNode_queryX(this.swigCPtr, OdRxClass.getCPtr(protocolClass)), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdGsMaterialNode createObject()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGsMaterialNode_createObject();
			OdGsMaterialNode result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGsMaterialNode)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGsMaterialNode)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGsMaterialNode)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGsMaterialNode(OdGsBaseModel pModel, OdGiDrawable pUnderlyingDrawable, bool bSetGsNode) : this(GlobalsPINVOKE.new_OdGsMaterialNode__SWIG_0(OdGsBaseModel.getCPtr(pModel), OdGiDrawable.getCPtr(pUnderlyingDrawable), bSetGsNode), true)
		{
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdGsMaterialNode(OdGsBaseModel pModel, OdGiDrawable pUnderlyingDrawable) : this(GlobalsPINVOKE.new_OdGsMaterialNode__SWIG_1(OdGsBaseModel.getCPtr(pModel), OdGiDrawable.getCPtr(pUnderlyingDrawable)), true)
		{
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public new virtual void destroy()
		{
			GlobalsPINVOKE.OdGsMaterialNode_destroy(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdGiMaterialTraitsData materialTraits()
		{
			OdGiMaterialTraitsData result = new OdGiMaterialTraitsData(GlobalsPINVOKE.OdGsMaterialNode_materialTraits__SWIG_0(this.swigCPtr), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual void onModified(OdGsBaseVectorizer view)
		{
			GlobalsPINVOKE.OdGsMaterialNode_onModified(this.swigCPtr, OdGsBaseVectorizer.getCPtr(view));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public new virtual void invalidate(OdGsContainerNode pParent, OdGsViewImpl pView, uint mask)
		{
			GlobalsPINVOKE.OdGsMaterialNode_invalidate(this.swigCPtr, OdGsContainerNode.getCPtr(pParent), OdGsViewImpl.getCPtr(pView), mask);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdGsMaterialNode nextNode()
		{
			OdGsMaterialNode result = (OdGsMaterialNode)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGsMaterialNode_nextNode(this.swigCPtr), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGsMaterialNode prevNode()
		{
			OdGsMaterialNode result = (OdGsMaterialNode)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGsMaterialNode_prevNode(this.swigCPtr), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGsMaterialNode setNextNode(OdGsMaterialNode newNode)
		{
			OdGsMaterialNode result = (OdGsMaterialNode)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGsMaterialNode_setNextNode(this.swigCPtr, OdGsMaterialNode.getCPtr(newNode)), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGsMaterialNode setPrevNode(OdGsMaterialNode newNode)
		{
			OdGsMaterialNode result = (OdGsMaterialNode)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGsMaterialNode_setPrevNode(this.swigCPtr, OdGsMaterialNode.getCPtr(newNode)), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool isDataModified()
		{
			bool result = GlobalsPINVOKE.OdGsMaterialNode_isDataModified(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool isCachedDataModified(OdGsBaseVectorizer view)
		{
			bool result = GlobalsPINVOKE.OdGsMaterialNode_isCachedDataModified(this.swigCPtr, OdGsBaseVectorizer.getCPtr(view));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setCachedDataUpdated(OdGsBaseVectorizer view)
		{
			GlobalsPINVOKE.OdGsMaterialNode_setCachedDataUpdated(this.swigCPtr, OdGsBaseVectorizer.getCPtr(view));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdRxObject cachedData(OdGsBaseVectorizer view)
		{
			OdRxObject result = Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGsMaterialNode_cachedData(this.swigCPtr, OdGsBaseVectorizer.getCPtr(view)), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setCachedData(OdGsBaseVectorizer view, OdRxObject newCachedData)
		{
			GlobalsPINVOKE.OdGsMaterialNode_setCachedData(this.swigCPtr, OdGsBaseVectorizer.getCPtr(view), OdRxObject.getCPtr(newCachedData));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public new virtual ENodeType nodeType()
		{
			ENodeType result = (ENodeType)GlobalsPINVOKE.OdGsMaterialNode_nodeType(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual bool saveNodeState(SWIGTYPE_p_OdGsFiler pFiler, OdGsBaseVectorizer pVectorizer)
		{
			bool result = GlobalsPINVOKE.OdGsMaterialNode_saveNodeState__SWIG_0(this.swigCPtr, SWIGTYPE_p_OdGsFiler.getCPtr(pFiler), OdGsBaseVectorizer.getCPtr(pVectorizer));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual bool saveNodeState(SWIGTYPE_p_OdGsFiler pFiler)
		{
			bool result = GlobalsPINVOKE.OdGsMaterialNode_saveNodeState__SWIG_1(this.swigCPtr, SWIGTYPE_p_OdGsFiler.getCPtr(pFiler));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual bool loadNodeState(SWIGTYPE_p_OdGsFiler pFiler, OdGsBaseVectorizer pVectorizer)
		{
			bool result = GlobalsPINVOKE.OdGsMaterialNode_loadNodeState__SWIG_0(this.swigCPtr, SWIGTYPE_p_OdGsFiler.getCPtr(pFiler), OdGsBaseVectorizer.getCPtr(pVectorizer));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual bool loadNodeState(SWIGTYPE_p_OdGsFiler pFiler)
		{
			bool result = GlobalsPINVOKE.OdGsMaterialNode_loadNodeState__SWIG_1(this.swigCPtr, SWIGTYPE_p_OdGsFiler.getCPtr(pFiler));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		private object locker = new object();

		private HandleRef swigCPtr;
	}
}
